﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="mo_khoa.aspx.cs" Inherits="App_Form_DaoTao_mo_khoa" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript" src="../../js/plugin/CheckColumn.js"></script>
    <link rel="stylesheet" type="text/css" href="../../shared/css/CheckHeader.css" />
    <script type="text/javascript">
        Ext.Loader.setConfig({
            enabled: true
        });
        Ext.Loader.setPath('Ext.ux', '../ux');

        Ext.require(['*']);

        Ext.require([
    'Ext.selection.CellModel',
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.state.*',
    'Ext.form.*',
    'Ext.grid.Panel',
     'Ext.ux.CheckColumn',
        'Ext.layout.container.Column'
        ]);


        Ext.onReady(function () {

            Ext.QuickTips.init();

            var bd = Ext.getBody();

            var gridForm = Ext.create('Ext.form.Panel', {
                id: 'company-form',
                frame: true,
                bodyPadding: 5,
                width: 620,
                layout: {
                    type: 'table',
                    columns: 2
                },
                fieldDefaults: {
                    labelAlign: 'left',
                    msgTarget: 'side'
                },

                items: [
                    {
                        columnWidth: '100%',
                        margin: '0 0 0 10',
                        xtype: 'fieldset',
                        title: 'Thông tin',
                        width: 600,
                        columnWidth: 1,
                        colspan: 2,
                        layout: 'anchor',
                        defaults: {
                            labelWidth: 100
                        },
                        defaultType: 'textfield',
                        items: [
                             {
                                 xtype: 'fieldcontainer',
                                 combineErrors: false,
                                 layout: {
                                     type: 'hbox',
                                     defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                                 },
                                 defaults: {
                                     hideLabel: true
                                 },
                                 items: [
                                 { xtype: 'displayfield', width: 80, value: 'Năm học' },
                                 {
                                     width: 150, xtype: 'combo', value: 'I', emptyText: 'Chọn năm học',
                                     triggerAction: 'all', forceSelection: true, editable: false,
                                     id: 'nam_hoc', name: 'nam_hoc', displayField: 'ten',
                                     valueField: 'id',
                                     queryMode: 'local',
                                     store: null
                                 },
                                 { xtype: 'displayfield', value: 'Học kỳ', width: 80 },
                                 {
                                     width: 150, xtype: 'combo', value: 'I',
                                     emptyText: 'Chọn học kỳ', triggerAction: 'all',
                                     forceSelection: true, editable: false, id: 'hoc_ky', name: 'hoc_ky', displayField: 'ten',
                                     valueField: 'id', queryMode: 'local', store: a_data
                                 }]
                             },
                        {
                            xtype: 'fieldcontainer',
                            combineErrors: false,
                            layout: {
                                type: 'hbox',
                                defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                            },
                            defaults: {
                                hideLabel: true
                            },
                            items: [
                                { xtype: 'displayfield', width: 80, value: 'Hệ đào tạo' },
                                {
                                    width: 150, xtype: 'combo',
                                    emptyText: 'Chọn hệ đào tạo', triggerAction: 'all', forceSelection: true,
                                    editable: false, id: 'he_dt', name: 'he_dt', displayField: 'Ten',
                                    valueField: 'ID', queryMode: 'local', store: null,
                                    listeners: {
                                        select: function (combo, record, index) {
                                            if (record.length > 0) {
                                                var id_ht_dt = record[0].get('ID');
                                                //Goi service
                                                wtkb.Fjson_Khoa_Lke(id_ht_dt, khoa_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                            }
                                        }
                                    }
                                },
                                { xtype: 'displayfield', width: 80, value: 'Khóa đào tạo' },
                                {
                                    width: 150, xtype: 'combo', triggerAction: 'all',
                                    emptyText: 'Chọn khóa', forceSelection: true,
                                    editable: false, id: 'khoa_dt',
                                    name: 'khoa_dt', displayField: 'Ten', valueField: 'ID',
                                    store: null,
                                    listeners: {
                                        select: function (combo, record, index) {
                                            if (record.length > 0) {
                                                var id_nganh = record[0].get('ID');
                                                //Goi service
                                                wtkb.Fs_LOP_KHOA(id_nganh, lophoc_nganh_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                            }
                                        }
                                    }
                                },
                                 {
                                     name: 'add',
                                     xtype: 'button',
                                     margin: '0 5 0 5',
                                     width: 100,
                                     icon: '../../shared/icons/fam/add.gif',
                                     text: 'Thêm mới',
                                     handler: function () {
                                         var b_nam = Ext.getCmp("nam_hoc").getValue(),
                                               b_hk = Ext.getCmp("hoc_ky").getValue();

                                         var b_tinhdiem = Ext.getCmp('tinhdiem');
                                         var a_gtriGrid = new Array();
                                         b_tinhdiem.getStore().each(function (record) {
                                             if (NVL(record.get("chon"), "") != "") {
                                                 a_gtriGrid[i] = NVL(record.get("id_lop"), "0");
                                             }
                                         });
                                         wdkhp.Fs_MO_KHOA_SO(b_nam, b_hk, a_gtriGrid, ren_luyen_nh_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                     }
                                 }
                                   
                            ]
                        }]
                    },
                    {
                        xtype: 'gridpanel',
                        margin: '5 0 0 10',
                        id: 'tinhdiem',
                        height: 350,
                        columnWidth: 1,
                        stateful: true,
                        Scroll: true,
                        plugins: Ext.create('Ext.grid.plugin.CellEditing', {
                            clicksToEdit: 1
                        }),
                        title: 'Danh sách lớp',
                        columns: [
                           { header: 'id_lop', hidden: true, dataIndex: 'id_lop' },
                           { header: 'Tên lớp', flex: 1, width: 120, dataIndex: 'ten_lop' },
                           {
                               header: 'Khóa', dataIndex: 'chon', width: 120, id: 'chon',
                               xtype: 'checkcolumn', cls: 'x-grid-checkheader-editor'
                           }
                        ]
                    }],
                renderTo: bd
            });
            wdkhp.Fs_NHAPDIEM_CH(P_LOAD_TTCHUNG, P_LOI_CSDL, P_LOI_TGIAN);
        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        function P_LOAD_TTCHUNG(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                var a_kq = b_kq.split('@');
                var b_chuoi1 = CH_JSON(a_kq[0]),
                    b_chuoi2 = CH_JSON(a_kq[1]);

                var a_data1 = Ext.create('Ext.data.Store', {
                    fields: ['id', 'ten'],
                    data: b_chuoi1
                });

                var b_chuoi4 = CH_JSON(a_kq[4]);
                var a_data4 = Ext.create('Ext.data.Store', {
                    fields: ['Ten', 'ID'],
                    data: b_chuoi4
                });
                var b_hk = Ext.getCmp("he_dt");
                b_hk.bindStore(a_data4);

                var cd = Ext.getCmp('nam_hoc');
                cd.bindStore(a_data1);

            }
        }
        function P_MON_NGANH_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {
                var b_chuoi = CH_JSON(b_kq);

                var a_data = Ext.create('Ext.data.Store', {
                    fields: ['Id_mon', 'TenMon'],
                    data: b_chuoi
                });

                var b = Ext.getCmp('mon_hoc');
                b.clearValue();
                b.setValue("");
                b.setValue(null);
                b.bindStore(a_data);
            }
        }
        function ren_luyen_nh_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            alert("Nhập thành công");
        }
       
        function nhaodiemP_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
        }
        function lophoc_nganh_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            var b_chuoi = CH_JSON(b_kq);
            var a_data = Ext.create('Ext.data.Store', {
                fields: ['id_lop', 'ten_lop'],
                data: b_chuoi
            });
            Ext.getCmp('lop').bindStore(a_data);
        }
        function lophoc_nganh_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            var b_chuoi = CH_JSON(b_kq);
            var a_data = Ext.create('Ext.data.Store', {
                fields: ['id_lop', 'ten_lop'],
                data: b_chuoi
            });
            Ext.getCmp('tinhdiem').bindStore(a_data);
        }
        function khoa_P_KQ(b_kq) {
            if (Fb_LOI_KTRA(b_kq)) {
                form_P_LOI(b_kq);
                return;
            }
            else {

                var b_chuoi1 = CH_JSON(b_kq);
                var a_data1 = Ext.create('Ext.data.Store', {
                    fields: ['ID', 'Ten', 'GhiChu'],
                    data: b_chuoi1
                });
                var c = Ext.getCmp('khoa_dt');
                c.bindStore(a_data1);
            }
        }
    </script>
</asp:Content>

